const path = require('path');
const webpackMerge = require('webpack-merge');
const baseConfig = require('./webpack.base.config');

const HtmlWebPackPlugin = require('html-webpack-plugin');
//用于在构建前清除dist目录中的内容
const { CleanWebpackPlugin } = require('clean-webpack-plugin');

module.exports = webpackMerge(baseConfig, {
    entry: './indextest.tsx', // 入口文件  有页面的
    mode: "development",
    devtool: "source-map",
    devServer: {
        hot: true, // 热替换
        contentBase: path.join(__dirname, 'dist'), // server文件的根目录
        compress: true, // 开启gzip
        port: 8081, // 端口
    },
    plugins: [
        // new webpack.HotModuleReplacementPlugin(), // HMR允许在运行时更新各种模块，而无需进行完全刷新
        new CleanWebpackPlugin(),
        new HtmlWebPackPlugin({
            template: './index.html',
            filename: path.resolve(__dirname, './dist/index.html')
        })
    ],
});